package ch3.LoadBalanceModule;

import java.util.Set;

/**
 * Candidate类包含了下游部件的节点列表（endpoints）和列表中所有节点的总权重
 */

public class Candidate {
    // 下游部件节点列表
    private final Set<Endpoint> endpoints;
    // 下游部件节点的总权重
    private final int totalWeight;

    public Candidate(Set<Endpoint> endpoints) {
        int sum = 0;
        for (Endpoint endpoint : endpoints) {
            sum += endpoint.weight;
        }
        totalWeight = sum;
        this.endpoints = endpoints;
    }

    public int getEndpointCount() {
        return endpoints.size();
    }

    public Set<Endpoint> getEndpoints() {
        return endpoints;
    }
}
